(function() {
  var dialog = Alchemy.currentDialog();
  var callback = function() {
    Alchemy.pleaseWaitOverlay();
    window.location.href = '<%= url_for(@redirect_url) %>';
  };
  if (dialog) {
    Alchemy.closeCurrentDialog(callback);
  } else {
    callback();
  }
})();
